package module4;

class Ticket1 extends Thread {
    private static int ticket = 100;
    public void run(){
        while (true){
            synchronized (Thread.class){
                if (ticket <= 0){
                    break;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(getName() + "还剩" + ticket-- + "张票");
            }
        }
    }
}
